export const parse2Seconds = (str) => {
  if (!/\d{2}:\d{2}/g.test(str)) {
    return 0;
  } else {
    return str.replace(/(\d{2}):(\d{2})/g, (str, $1, $2) => {
      return +$1 * 60 + (+$2);
    });
  }
};

export const parse2Minutes = (num) => {
  const minutes = Math.floor(num / 60) < 10 ? `0${Math.floor(num / 60)}` : Math.floor(num / 60);
  const seconds = num % 60 < 10 ? `0${num % 60}` : num % 60;
  return `${minutes}:${seconds}`
};